package com.fl.sliderverification

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.Toast
import com.fl.sliderverification.dialog.CaptchaSecurityDialog
import com.fl.sliderview.SliderVerificationView
import com.lxj.xpopup.XPopup

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // 滑块
        findViewById<SliderVerificationView>(R.id.mSvv).setOnVerificationResultListener(object :
            SliderVerificationView.OnVerificationResultListener {
            override fun onVerificationSuccess(slideDuration: Long) {
                Toast.makeText(this@MainActivity,"成功--使用时间:${slideDuration}毫秒",Toast.LENGTH_SHORT).show()
            }

            override fun onVerificationError(slideDuration: Long) {
                Toast.makeText(this@MainActivity,"失败--使用时间:${slideDuration}毫秒",Toast.LENGTH_SHORT).show()
            }
        })

        // 启动弹窗
        findViewById<Button>(R.id.mBtnOpenDialog).setOnClickListener {

            val dialog = CaptchaSecurityDialog(this)
            XPopup.Builder(this)
                .isDestroyOnDismiss(true) //对于只使用一次的弹窗，推荐设置这个
                .asCustom(dialog)
                .show()

        }

    }
}